From ac70d5694662b32daf215129d9c7d7bb62176c19 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 2 Dec 2005 11:05:49 +0100 Subject: [PATCH] Avoid ns16550 poll timeout underflow. Signed-off-by: Alex Williamson Signed-off-by: Keir Fraser --- xen/drivers/char/ns16550.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 4595dc08ed..b7d24107b6 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -211,7 +211,8 @@ static void ns16550_init_postirq(struct serial_port *port) { /* Polled mode. Calculate time to fill RX FIFO and/or empty TX FIFO. */ bits = uart->data_bits + uart->stop_bits + !!uart->parity; - uart->timeout_ms = (bits * port->tx_fifo_size * 1000) / uart->baud; + uart->timeout_ms = max_t( + unsigned int, 1, (bits * port->tx_fifo_size * 1000) / uart->baud); init_ac_timer(&uart->timer, ns16550_poll, port, 0); set_ac_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms)); } -- 2.30.2